package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.db.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface LogMapper extends BaseMapper<Log> {

    //1.查询新注册的用户数
    @Select("select count(distinct user_id) from tb_log where log_time=#{logTime} and type=#{type}")
    Integer queryByLogTimeAndType(@Param("type") String type,@Param("logTime") String logTime);

    //2.查询活跃用户数
    @Select("select count(distinct user_id) from tb_log where log_time=#{today}")
    Integer queryByLogTime(String today);

    //3.统计次日留存数量
    @Select("select count(distinct user_id) from tb_log where log_time=#{today} and user_id in (\n" +
            "\tselect user_id from tb_log where log_time=#{yesterDay}   and type='0102'\n" +
            ")\n")
    Integer queryNumRetention1d(@Param("today") String today, @Param("yesterDay") String yesterDay);


}
